/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}

export function validator(type, value) {
    // let types = {
    //     alphaDash   : /^[A-Za-z0-9\-\_]+$/,
    //     chs         : /^[\x{4e00}-\x{9fa5}]+$/u,
    //     chsAlpha    : /^[\x{4e00}-\x{9fa5}a-zA-Z]+$/u,
    //     chsAlphaNum : /^[\x{4e00}-\x{9fa5}a-zA-Z0-9]+$/u,
    //     chsDash     : /^[\x{4e00}-\x{9fa5}a-zA-Z0-9\_\-]+$/u,
    //     mobile      : /^1[3-9][0-9]\d{8}$/,
    //     idCard      : /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
    //     zip         : /\d{6}/,
    // };
}